package com.zcxx.cotton.sale;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.zcxx.cotton.sale.domain.SaleInfo;
import com.zcxx.cotton.sale.service.ISaleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 吴璇璇
 * @title: BuySaleinfosController
 * @projectName ruoyi
 * @description: TODO
 * @date 2025/7/28 16:34
 */

@RestController
@RequestMapping("/buy/saleinfos/")
public class BuySaleinfosController extends BaseController {

    @Autowired
    private ISaleInfoService saleInfoService;

    /**
     * 查询列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SaleInfo saleInfo)
    {
        startPage();
        startOrderBy();
        List<SaleInfo> list = saleInfoService.selectSaleinfosList(saleInfo);
        return getDataTable(list);
    }
    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('pick:info:add')")
    @Log(title = "新增交售信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaleInfo saleInfo)
    {
        return toAjax(saleInfoService.insertSaleInfo(saleInfo));
    }


    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('pick:info:edit')")
    @Log(title = "修改交售信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaleInfo saleInfo)
    {
        return toAjax(saleInfoService.updateSaleInfo(saleInfo));
    }
    /**
     * 获取详细信息
     */
    @GetMapping(value = "/{saleinfosId}")
    public AjaxResult getInfo(@PathVariable("saleinfosId") Long saleinfosId)
    {
        return success(saleInfoService.selectSaleInfoBySaleinfosId(saleinfosId));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('pick:info:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{saleinfosIds}")
    public AjaxResult remove(@PathVariable Long[] saleinfosIds)
    {
        return toAjax(saleInfoService.deleteSaleInfoBySaleinfosIds(saleinfosIds));
    }
}
